<link href="css/page.css" type="text/css" rel="stylesheet">
<style type="text/css">
button{cursor: pointer;}
table{width:100%;margin-bottom:10px;}
.fenyeiWrap{width:100%;position: relative;top: 30px;margin-top:10px;}
.fenyeiWrap .span3,#whickPage{display:none;}
th,td{text-align:center;}
.content{width:80%;float:right;}
.mc_title {border-bottom: 3px solid #2A98DA;padding-left: 36px;}
.mc_title .mctit_1 {background: url("../images/mc_title.png") no-repeat scroll left bottom rgba(0, 0, 0, 0);display: inline-block;height: 27px;padding-left: 15px;}
.mc_title .mctit_2 {background: url("../images/mc_title.png") no-repeat scroll right top rgba(0, 0, 0, 0);color: #FFFFFF;display: inline-block;font-size: 14px;font-weight: bold;height: 27px;line-height: 29px;padding-right: 15px;}
.s{padding:20px 10px;}
.ps{color:red; margin-bottom:5px;}
.ps label{color:#2A98DA; font-size:16px; font-weight:bold; margin-right:20px; padding-left:10px;}
.ps span{float:right; line-height:26px; line-height:28px\9;}
#txt{margin-right:15px; color:#888;}
#class{margin-right:25px;}
tr{border-bottom:1px solid #B0DFFD; height:35px;}
tr.tt{border-top:1px solid #B0DFFD; background:#F3FAFF;height:30px;}
.space{height:10px;}
.pri{width:50px;height:20px;text-align:center;}
.p_t{display:block; position:absolute; right:75px; top:3px; top:4px\9; width:40px;}
.add,.rude{display:block; width:10px; height:11px; border:1px solid; line-height:9px; line-height:8px\9; padding-right:1px; font-size:15px; cursor:pointer;}
.add{position: absolute; right:-20px; top:5px;}
.rude{position:absolute;right:60px; top:5px;}
.fenyeiWrap{float:right;margin-top:0;}
.txtlf{ text-align:left; padding-left:8px;}
.btnmcc{width:78px;height: 30px;border: 0;position: relative;float: right;top: -35px;background: url(http://www.12301.cc/images/btnbc.png) no-repeat;line-height: 30px;color: white;font-weight: bold;cursor: pointer;}
#dialog { background-color:#fff;border:5px solid rgba(0,0,0, 0.4);  height:300px; left:50%; margin:-200px 0 0 -200px; padding:10px; position:fixed !important; /* 浮动对话框 */ 
position:absolute; top:50%; width:450px; z-index:100; border-radius:5px; display:none;  } 
#dialog p { margin:0 0 12px; line-height:24px; background:#CCCCCC; } 
#dialog p.close { text-align:right; padding-right:10px; } 
#dialog p.close a { color:#fff; text-decoration:none; } 
#fullbg { z-index:1000;background-color:gray; opacity:0.5; position:absolute; top:0; z-index:99; filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity:0.5; } 
.adjusting_font{font: 微软雅黑,tahoma,arial,宋体;font-size:1.1em;}
.adjusting_font i{color:red;font-weight: bold;}
span.adj_span{float:left;margin-top:10px;}
.d_save{width: 100px;height: 30px;float: right;margin-right: 10px;line-height: 30px;border: 0;font-size: 1.4em;
background-color: #00a0e9;text-align: center;font-weight: normal;color: #FFF;margin-top: 10px;cursor: pointer;}
.adj_span{color:red;font-weight:bold;font-size:1.2em;font: 微软雅黑,tahoma,arial,宋体;}
</style>
<script type="text/javascript">
function pri(){
	var p=$('#p_t').val();
	$('#form table tbody tr td input:text').each(function(i,e){
		e.value=p;
	})
}
function chAll(e){//(取消)全选
	var x=document.getElementsByTagName("input");
	for(var i=0;i<x.length;i++){
		var obj = x[i];
		if(obj.type=="checkbox"){
			if(e.checked)
				obj.checked=true;
			else
				obj.checked=false;
		}
	}  
}
function cl(c){
	if(c.value=="分销商名称/账号"){
		c.value="";
		c.style.color="#000";
		return;
	}
	if(c.value==""){
		c.value="分销商名称/账号";
		c.style.color="#888";
		return;
	}
}
function sale(c){
	if(c.value=="禁售"){
		c.value="";
		c.style.color="#000";
		return;
	}
	if(c.value==""){
		c.value="禁售";
		c.style.color="#999";
		return;
	}
}

function showBg(a) { 

	var bh = $("html").height(); 
	var bw = $("html").width(); 
	flag = false;
	$("#fullbg").css({ 
		height:bh, 
		width:bw, 
		display:"block" 
	});
	var data = JSON.parse(a),i,html='';
	for(i in data){
		html+='<span class="adj_span"><input type="checkbox" class="set_on"/>'+data[i].dname+'';
		html+='<input type="hidden" name="sets['+data[i].fid+']" value="'+data[i].id+'" disabled="disabled" class="set_data"/>';
		html+='</span>';
	}
	$(".list_area").html(html);
	$("#dialog").show(); 
	// if(flag) return false;
	 // $.getJSON('call/pppp.php',{action:'adjusting_list'},function(data){
		// _ds = data.key;
		// _html = '<li class="itemLi odd selected" data="'+_ds+'">';
		// _html +='<ul class="topUl">';
		// _html +='<li class="tcol_1 tcol">'+data.title+'</li>';
		// _html +='<li><input type="submit" class="d_save" value="保存"></li>';
		 // $(".listWrap").html(_html);
	// });
}

function closeBg() { 
	$("#fullbg,#dialog").hide(); 
}
function bingo(){
	$(".set_on").each(function(i,element){
		if($(this).is(":checked")){
			$(".set_data").eq(i).removeAttr("disabled");
		}else{
			$(".set_data").eq(i).attr("disabled","disabled");
		}
	});
	$(".sts").submit();
	closeBg();
	return false;
}

</script>
<div class="content">
	<h3 class="mc_title">
		<span class="mctit_1">
			<span class="mctit_2">分销价格配置</span>
		</span>
	</h3>
	<iframe name="ifr" style="display:none;"></iframe>
  <form action="" target="ifr" id="form" method="post">
	<div class="s">
		<input type="hidden" name="pid" value="<?=$pid?>"/>
		<input type="hidden" name="lvl" value="<?=$lvl?>"/>
		<input type="hidden" name="sourceid" value="<?=$sourceid?>"/>
		<input type="hidden" name="aids" value="<?=$aids?>"/>
        <input type="hidden" name="sid" value="<?=$sid?>"/>
		<label for="txt">查询条件：</label><input type="text" name="txt" id="txt" onfocus="cl(this)" onblur="cl(this)" value="<?=$txt?>" />
		<label for="class">所属分类：</label>
		<select name="class" id="class">
			<option value="">请选择分类</option>
		<?	foreach($c as $k=>$v){?>
			<option <?if($k==$class)echo "selected";?> value="<?=$k?>"><?=$v?></option>
		<?	}?>
		</select>
		<button type="button" onclick="$('#form').attr({'action':'','target':''}).submit();"> 提交查询 </button>
	</div>
	<p class="ps"><label><?=$ltitle?>(<?=$ttitle?>)</label>供货价：<?=$fp?>元<span>注：修改仅作用于勾选的分销商,未配置价格(空)为禁售状态。</span></p>
	<table>
		<tr class="tt">
			<th style="width:40px"><input type="checkbox" checked onclick="chAll(this)" /></th>
			<th class="txtlf">分销商名称（账号）</th>
			<th>
				<div style="position:relative; display:inline-block;" >
                    <span onclick="$('#p_t').val($('#p_t').val()-1);pri()" class="rude">-</span>
                    <input type="text" name="one_price" id="p_t" onkeyup="pri()" class="pri" value="<?=$fp?>"/>   
					<span onclick="$('#p_t').val(Number($('#p_t').val())+Number(1));pri()" class="add">+</span>
                    <span class="p_t">结算价</span>
                </div>
                <?php if($_GET['more']):?>
                <button type="button"
                        id="OneKeySet"
                        title="所有分销商设置统一的分销商价"
                        onclick="$('#form').attr({'action':'adjusting_batch.php','target':'ifr'}).submit();" style="margin-left: 32px;">一键设置</button>
                <?php endif;?>
			</th>
		</tr>
	<?	foreach($dist as $k=>$v){
		//if($ptype=='F'&&in_array($v['id'],$chain_distributor)) continue;
		//	$color=$pri[$v['id']]==""?"color:#999":"";?>
		<tr>
			<td><input type="checkbox" name="did[]"  checked  value="<?=$v['id']?>" /></td>
			<td class="txtlf"><?=$v['dname']?>（ID:<?=$v['account']?>）</td>
			<input type="hidden" name="sPri[<?=$v['id']?>]" class="pri" value="<?=$pri[$v['id']]?>" />
			<td>
                <input type="text" style="<?=$color?>" name="pri[<?=$v['id']?>]" class="pri" value="<?=$pri[$v['id']]?>" />
            </td>
		</tr>
	<?	}?>
	</table>
	<?page($total,$currentPage,$pageSize);?>
  </form>
    <?if($_REQUEST['a']):?>
	<button type="button" onclick="$('#form').attr({'action':'adjusting_dt.php','target':'ifr'}).submit();" class="btnmcc"> 保存配置 </button>
    <?else:?>
    <button type="button" onclick="$('#form').attr({'action':'adjusting.php','target':'ifr'}).submit();" class="btnmcc"> 保存配置 </button>
    <?endif;?>
</div>
<div id="fullbg"></div> 
<div id="dialog"> 
<p class="close"><a href="#" onclick="closeBg();">关闭</a>  
<div class="listWrap">
	<form action="adjusting_set.php" meth="post" target="ifr" class="sts">
	<div class="adjusting_font">以下分销商可销售产品以达<i>500</i>个，如果还想继续分销，须配置全部可销售，请确定</div>
	<div class="list_area">
	
	</div>
	<ul id="mlistUl" class="listUl">
		<li><input type="button" class="d_save" value="保存" onclick="bingo()"></li>
	</ul>
	</form>
</div>
</div>